//
//  QXQingXingViewController.m
//  qiJi
//
//  Created by 凤利史 on 2018/3/27.
//  Copyright © 2018年 sunrose. All rights reserved.
//

#import "QXQingXingViewController.h"
#import "QXShuJuViewController.h"
#import "QXBenYueQiXingViewController.h"
#import "QXHaoYouPaiHangViewController.h"
#import "QXSheZhiViewController.h"
#import "QXZuTuanQiXingViewController.h"

#import "DiTuDaoHangViewController.h"//地图导航

@interface QXQingXingViewController ()
@property (nonatomic, strong) UIButton *zongGLBtn;//总公里数
@property (nonatomic, strong) UIButton *benYueQXBtn;//本月骑行
@property (nonatomic, strong) UIButton *haoYouPaiHBtn;//好友排行榜
@end

@implementation QXQingXingViewController

- (void)zj_viewDidLoadForIndex:(NSInteger)index {
    
    
    
    
}
- (void)zj_viewWillAppearForIndex:(NSInteger)index {
    // NSLog(@"viewWillAppear------");
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    
}


- (void)zj_viewDidAppearForIndex:(NSInteger)index {
    // NSLog(@"viewDidAppear-----");
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = CLColor(245, 245, 245);
    [self loadSubviews];
    
    // Do any additional setup after loading the view.
}
//布局
- (void)loadSubviews{
    UILabel *zongGL = [[UILabel alloc] init];
    [self.view addSubview:zongGL];
    [zongGL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).with.offset(45*CHANGE_SIZE);
        make.centerX.equalTo(self.view);
        
    }];
    zongGL.text = @"总公里数";
    zongGL.textColor = getColor(@"333333");
    zongGL.font = [UIFont fontWithName:@"DINEngschrift LT Alternate" size:16];
    
    _zongGLBtn = [[UIButton alloc] init];
    [self.view  addSubview:_zongGLBtn];
    [_zongGLBtn setTitle:@"133" forState:UIControlStateNormal];
    [_zongGLBtn setTitleColor:getColor(@"333333") forState:UIControlStateNormal];
    _zongGLBtn.titleLabel.font = [UIFont fontWithName:@"DINEngschrift LT Alternate" size:30*CHANGE_SIZE];
    [_zongGLBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(zongGL.mas_bottom).with.offset(20*CHANGE_SIZE);
        make.centerX.equalTo(zongGL);
        
    }];
    UILabel *benYueLab = [[UILabel alloc] init];
    [self.view  addSubview:benYueLab];
    benYueLab.text = @"本月骑行 (km)";
    [benYueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(CHANGE_SIZE*39);
        make.top.equalTo(_zongGLBtn.mas_bottom).with.offset(35*CHANGE_SIZE);
        
        
    }];
    benYueLab.textColor = getColor(@"666666");
    benYueLab.font = [UIFont systemFontOfSize:14*CHANGE_SIZE];
    self.benYueQXBtn = [[UIButton alloc] init];
    [self.view  addSubview:self.benYueQXBtn];
    [self.benYueQXBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(benYueLab.mas_bottom).with.offset(CHANGE_SIZE*16);
        make.centerX.equalTo(benYueLab);
        
    }];
    [self.benYueQXBtn setTitle:@"33" forState:UIControlStateNormal];
    [_benYueQXBtn setTitleColor:getColor(@"333333") forState:UIControlStateNormal];
    _benYueQXBtn.titleLabel.font = [UIFont fontWithName:@"DINEngschrift LT Alternate" size:17*CHANGE_SIZE];
    [_benYueQXBtn addTarget:self action:@selector(benYueClick) forControlEvents:UIControlEventTouchUpInside];
    
    UILabel *haoYouPaiHangLab = [[UILabel alloc] init];
    [self.view  addSubview:haoYouPaiHangLab];
    
    haoYouPaiHangLab.text = @"好友排行榜";
    haoYouPaiHangLab.textColor = getColor(@"666666");
    haoYouPaiHangLab.font = [UIFont systemFontOfSize:14*CHANGE_SIZE];
    [haoYouPaiHangLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view).with.offset(-CHANGE_SIZE*39);
        make.top.equalTo(_zongGLBtn.mas_bottom).with.offset(35*CHANGE_SIZE);
        
    }];
    
    _haoYouPaiHBtn = [[UIButton alloc] init];
    [self.view  addSubview:_haoYouPaiHBtn];
    [_haoYouPaiHBtn setTitle:@"22" forState:UIControlStateNormal];
    [_haoYouPaiHBtn setTitleColor:getColor(@"333333") forState:UIControlStateNormal];
    _haoYouPaiHBtn.titleLabel.font = [UIFont fontWithName:@"DINEngschrift LT Alternate" size:17*CHANGE_SIZE];
    [_haoYouPaiHBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(haoYouPaiHangLab.mas_bottom).with.offset(CHANGE_SIZE*16);
        make.centerX.equalTo(haoYouPaiHangLab);
        
    }];
    [_haoYouPaiHBtn addTarget:self action:@selector(haoYouPaiHangClick) forControlEvents:UIControlEventTouchUpInside];
    
    //背景半圆
    UIImageView * bg = [[UIImageView alloc] init];
    [self.view  addSubview:bg];
    [bg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_haoYouPaiHBtn.mas_bottom).with.offset((KIsiPhoneX?30*CHANGE_SIZE:20*CHANGE_SIZE));
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        
    }];
    bg.image = [UIImage imageNamed:@"home_bg"];
   // bg.contentMode = UIViewContentModeScaleAspectFill;
    
    
    //大按钮
    UIButton * bigBtn = [[UIButton alloc] init];
    [self.view addSubview: bigBtn];
    [bigBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(170*CHANGE_SIZE);
        make.height.offset(170*CHANGE_SIZE);
        make.centerX.equalTo(bg);
        make.top.equalTo(bg).with.offset(30*CHANGE_SIZE);
        
    }];
    [bigBtn setBackgroundImage:[UIImage imageNamed:@"home_action_btn_normal"] forState:UIControlStateNormal];
    [bigBtn setBackgroundImage:[UIImage imageNamed:@"home_action_btn_pre"] forState:UIControlStateHighlighted];
    [bigBtn setTitle:@"立即骑行" forState:UIControlStateNormal];
    bigBtn.titleLabel.font = [UIFont systemFontOfSize:18*CHANGE_SIZE];
    [bigBtn addTarget:self action:@selector(liShuNumBtnAction) forControlEvents:UIControlEventTouchUpInside];
    
    
    //下面3个按钮
    NSArray * titleArr = @[@"地图导航",@"组队骑行",@"骑行设置"];
    NSArray * logoArr = @[@"home_map_btn",@"home_team_btn",@"home_set-up_btn"];
    for (int i = 0; i<3; i++) {
        UIButton * btn = [[UIButton alloc] initWithFrame:CGRectMake(25+(55+(DEF_SCREEN_WIDTH-55*3-50)/2)*i, DEF_SCREEN_HEIGHT - 25*CHANGE_SIZE- (KIsiPhoneX?137:113) - 44, 55, 44)];
        [btn setImage:[UIImage imageNamed:logoArr[i]] forState:UIControlStateNormal];
        [btn setTitle:titleArr[i] forState:UIControlStateNormal];
        btn.titleLabel.font = [UIFont systemFontOfSize:13];
        [btn setTitleColor:JH9GrayColor forState:UIControlStateNormal];
        btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示
        [btn setTitleEdgeInsets:UIEdgeInsetsMake(btn.imageView.frame.size.height+9 ,-btn.imageView.frame.size.width, 0.0,0.0)];//文字距离上边框的距离增加imageView的高度，距离左边框减少imageView的宽度，距离下边框和右边框距离不变
        [btn setImageEdgeInsets:UIEdgeInsetsMake(-10, (55-22)/2,0.0,0.0)];//图片距离右边框距离减少图片的宽度，其它不边
        btn.tag = 120+i;
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:btn];
    }
    
    
    
}
- (void)btnClick:(UIButton* )sender{
    if (sender.tag ==122) {
        QXSheZhiViewController *vc = [[QXSheZhiViewController alloc] init];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    }else if (sender.tag ==121) {
        
        QXZuTuanQiXingViewController *vc = [[QXZuTuanQiXingViewController alloc] init];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    }else {
        
        DiTuDaoHangViewController *vc = [[DiTuDaoHangViewController alloc] init];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
        
        
    }
    
    
}
//本月骑行距离
- (void)benYueClick{
    
    QXBenYueQiXingViewController *vc = [[QXBenYueQiXingViewController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
    
    
}
//好友排行
- (void)haoYouPaiHangClick{
    QXHaoYouPaiHangViewController *vc = [[QXHaoYouPaiHangViewController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
    
}
//立即骑行
- (void)liShuNumBtnAction{
    
    QXShuJuViewController *vc = [[QXShuJuViewController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
